package com.yjlove.myplay.jsinter;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.webkit.JavascriptInterface;

import com.yjlove.myplay.MainActivity;
import com.yjlove.myplay.ui.activity.WebViewX5TestActivity;

/**
 * 作者 YJlvoe
 * 创建时间 2017/4/12.
 */
public class JavaScriptInterface {
    private Activity mActivity;
    private Intent mIntent;
    public JavaScriptInterface(Activity activity) {
        mActivity = activity;
    }

    @JavascriptInterface
    public void displayMainActivity() {
        mIntent = new Intent(mActivity, MainActivity.class);
        mActivity.startActivity(mIntent);
        mActivity.finish();
    }

    @JavascriptInterface
    public void displayX5Activity() {
        mIntent = new Intent(mActivity, WebViewX5TestActivity.class);
        mActivity.startActivity(mIntent);
        mActivity.finish();
    }

    @JavascriptInterface
    public void callPhone(String number) {
        Intent dialIntent =  new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + number));//跳转到拨号界面，同时传递电话号码
        mActivity.startActivity(dialIntent);
    }
}
